SVG Examples

Must Watch!

MustWatch



SVG SVG Clock

JS: SVG Clock

SVG Basic Shapes

A circle A rectangle A rectangle with opacity A rectangle with opacity 2 A rectangle with rounded corners An ellipse Three ellipses on top of each other Two ellipses A line A polygon with three sides A polygon with four sides A star Another star A polyline Another polyline A path A quadratic Bézier curve Write a text Rotate a text Text on several lines Text as a link Defines the color of a line, text or outline (stroke) Defines the width of a line, text or outline (stroke-width) Defines different types of endings to an open path (stroke-linecap) Defines dashed lines (stroke-dasharray)

Path commands

https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d Path commands are instructions that define a path to be drawn. Each command is composed of a command letter and numbers that represent the command parameters. SVG defines 6 types of path commands, for a total of 20 commands: MoveTo: M , m. LineTo: L , l , H , h , V , v. Cubic Bézier Curve: C , c , S , s. Quadratic Bézier Curve: Q , q , T , t. Elliptical Arc Curve: A , a. ClosePath: Z , z.

SVG Filters

feGaussianBlur - blur effect feOffset - offset a rectangle, then blend the original on top of the offset image feOffset - blur the offset image feOffset - make the shadow black feOffset - treat the shadow as a color A feBlend filter Filter 1 Filter 2 Filter 3 Filter 4 Filter 5 Filter 6

SVG Gradients

An ellipse with a horizontal linear gradient from yellow to red An ellipse with a vertical linear gradient from yellow to red An ellipse with a horizontal linear gradient from yellow to red, and a text An ellipse with a radial gradient from white to blue Another ellipse with a radial gradient from white to blue

SVG Misc

Rectangle that repeatedly fade away over 5 seconds A growing rectangle that will change color Three rectangles that will change color Move text along a motion path Move, rotate, and scale text along a motion path Move, rotate, and scale text along a motion path + a growing rectangle that will change color Rotating ellipses

Use external SVG in HTML

SVG `use` with External Source

Create a rounded rectangle with SVG Path

Explanation m100,100: move to point(100,100) h200: draw a 200px horizontal line from where we are a20,20 0 0 1 20,20: draw an arc with 20px X radius, 20px Y radius, clockwise, to a point with 20px difference in X and Y axis v200: draw a 200px vertical line from where we are a20,20 0 0 1 -20,20: draw an arc with 20px X and Y radius, clockwise, to a point with -20px difference in X and 20px difference in Y axis h-200: draw a -200px horizontal line from where we are a20,20 0 0 1 -20,-20: draw an arc with 20px X and Y radius, clockwise, to a point with -20px difference in X and -20px difference in Y axis v-200: draw a -200px vertical line from where we are a20,20 0 0 1 20,-20: draw an arc with 20px X and Y radius, clockwise, to a point with 20px difference in X and -20px difference in Y axis z: close the path svg rounded corner